list1 = ['python', 'java', 'javaScript', 'php', 'golang']

# 索引正数
print(list1[0:2]) # ['python','java']
print(list1[:2])# ['python','java']
print(list1[2:])# javaScript,php,golang
print(list1[:])#python,java,javaScript,php,golang
#索引负数
print(list1[-4:-1]) # java,javascript,php
print(list1[:-1])# python,java,javascript,php

# 步长为正数,从左往右;步长为负数,从右往左
print(list1[-5:-2])# python,java,javascript
print(list1[-5:-2:-1])#[]
print(list1[-2:-5:-1])
print(list1[-2:-5:-2])
